<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加成绩</title>
    <link href="../../static/css/bootstrap.min.css" rel="stylesheet" th:href="@{/static/css/bootstrap.min.css}">
    <link href="../../static/css/dashboard.css" rel="stylesheet" th:href="@{/static/css/dashboard.css}">
</head>
<body>
<div th:insert="admin/common::topbar"></div>
<div class="container-fluid">
    <div class="row">
        <!--侧边栏-->
        <div th:insert="~{admin/common::sidebar(active='examArrange.html')}">
        </div>
        <!--"-->
        <main class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4" role="main">
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
                <h3>上成绩</h3>
                <div class="btn-toolbar mb-2 mb-md-0">
                    <div class="btn-group mr-2">
                        <button class="btn btn-sm btn-outline-secondary" id="btn-quit-arrange-stuGrade">退出编辑</button>
                    </div>
                    <div class="btn-group mr-2">
                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-admin">管理员</button>
                        <button class="btn btn-sm btn-outline-secondary" id="btn-student">学生端</button>
                    </div>
                </div>
            </div>
            <form class="container-fluid col-md-5 col-md-pull-3" id="myForm" method="post"
                  th:action="@{/admin/addStuExamGrade}">
                <p th:if="${not #strings.isEmpty(error)}" th:text="${error}"></p>
                <div class="form-group form-inline" hidden>
                    <label class="form-check-inline" for="exam_id">考试编号:</label>
                    <input class="form-control" id="exam_id" name="exam_id" readonly th:value="${exam.getExam_id()}"
                           type="text">
                </div>
                <div class="form-group form-inline">
                    <label class="form-check-inline" for="exam_name">考试名称:</label>
                    <input class="form-control" id="exam_name" name="exam_name" readonly
                           th:value="${exam.getExam_name()}" type="text">
                </div>
                <div class="form-group form-inline" hidden>
                    <label class="form-check-inline" for="exam_cid">考试科目编号:</label>
                    <input class="form-control" id="exam_cid" name="exam_cid" readonly th:value="${exam.getExam_cid()}"
                           type="text">
                </div>
                <div class="form-group form-inline">
                    <label class="form-check-inline" for="exam_cname">考试科目:</label>
                    <input class="form-control" id="exam_cname" name="exam_cname" readonly
                           th:value="${exam.getExam_cname()}" type="text">
                </div>
                <div class="form-group form-inline">
                    <label class="form-check-inline" for="sno">考生学号:</label>
                    <input class="form-control" id="sno" name="sno" readonly th:value="${exam.getSno()}" type="text">
                </div>
                <div class="form-group form-inline">
                    <label class="form-check-inline" for="sname">考生姓名:</label>
                    <!--<select class="form-control" name="exam_time" id="exam_time">
                        <option th:each="time:${timeList}" th:text="${time.getDuration()}" th:value="${time.getDuration()}"></option>
                    </select>-->
                    <input class="form-control" id="sname" name="sname" readonly th:value="${exam.getSname()}"
                           type="text">
                </div>
                <div class="form-group form-inline">
                    <label class="form-check-inline" for="grade">考试成绩:</label>
                    <!--<select class="form-control" name="exam_time" id="exam_time">
                        <option th:each="time:${timeList}" th:text="${time.getDuration()}" th:value="${time.getDuration()}"></option>
                    </select>-->
                    <input class="form-control" id="grade" name="grade" oninput="value=value.replace(/[^\d]/g,'')"
                           type="text">
                    <p hidden id="msg" style="color: red"></p>
                </div>
                <div class="form-group form-inline">
                    <button class="btn btn-primary " id="button" type="submit">添加</button>
                </div>
            </form>

        </main>
    </div>
</div>
<script src="../../static/js/jquery-3.6.0.min.js" th:src="@{/static/js/jquery-3.6.0.min.js}"
        type="text/javascript"></script>
<script src="../../static/js/bootstrap.min.js" th:src="@{/static/js/bootstrap.min.js}" type="text/javascript"></script>
<script src="../../static/js/btn.js" th:src="@{/static/js/btn.js}"></script>
<script>
    $(function () {
        $('#btn-quit-arrange-stuGrade').click(function () {
            let exam_id = [[${exam.getExam_id()}]];
            let exam_cid = [[${exam.getExam_cid()}]];
            let sno = [[${exam.getSno()}]];
            $(location).attr('href', '/admin/showStuExamInfo/' + exam_id + '/' + exam_cid + '/' + 1);
        })
        $('#grade').blur(function () {
            //alert("运行以下");
            let grade = $('#grade');
            let subject = $('#exam_cname');
            /*  if (grade.text()<'0'||grade.text()>'150'){
                  alert("你输入的分数不对！");
                  grade.val("");
              }*/
            if (subject.val() === '语文' || subject.val() === '数学' || subject.val() === '英语') {
                if (parseFloat(grade.val()) < 0 || parseFloat(grade.val()) > 150) {
                    alert("你输入的分数不对！");
                    grade.val("");
                }
            } else {
                if (parseFloat(grade.val()) < 0 || parseFloat(grade.val()) > 100) {
                    alert("你输入的分数不对！");
                    grade.val("");
                }
            }
        })
    })

</script>
</body>
</html>